import Vue, { VNode, CreateElement, ComponentOptions } from 'vue';

/**
 * 创建动态模板飘窗容器
 *
 * @param {ComponentOptions<Vue>} options
 */
export const createDrawerContainer = (options: ComponentOptions<Vue> = {}) => {
  return {
    props: ['dynamicProps', 'staticProps', 'modal'],
    render(h: CreateElement): VNode {
      const self: any = this;
      return h(
        'div',
        {
          staticClass: 'app-top-drawer-wrapper',
        },
        [
          h('app-view-shell', {
            on: {
              close: (e: any) => {
                self.modal.dismiss(e);
              },
            },
            props: {
              dynamicProps: self.dynamicProps,
              staticProps: self.staticProps,
              modal: self.modal,
            },
          }),
        ],
      );
    },
    ...options,
  };
};
